 <?
        require_once('header.php'); // uri  
        ?>
    <link rel="stylesheet" href="css/createshelf.css">
    <script src="js/binaryajax.js"></script>
    <script src="js/exif.js"></script>
    <script src="js/canvasResize.js"></script>
    <script type="text/javascript" src="js/uploadbird.js"></script>
    <script type="text/javascript" src="js/uploadfilebird.js"></script>
    
    <script type="text/javascript" src="js/media/js/jquery.dataTables.js"></script>
        <!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]-->
        
            <div class="wrpInnerBody">

                <?
        require_once('subheader.php'); // uri  
        ?>      

                <div class="wrpContent">
                    <div class="wrpInnerContent">
                        <?
                        require_once('headeradmin.php'); // uri  
                        
                        //$shelf=$this->data['editshelf']['shelf'];

                        ?>                   
                        <div class="wrapper">
                            <!--<form class="formCreateShelf" name="formCreateShelf" id="formCreateShelf"> -->
                                <div class="wrapCreateShelfandUser">
                                    <div class="wrapCreateShelf">
                                        <p class="textCreateShelf titleCreate"><?if($this->data['label']){ echo $this->data['label']; }else {?>Create <?}?> Shelf</p>
                                        <div class="wrapTmbnlShelf">
                                            <div id="droppic"><img id="imgshelf" class="upThumImg" src="<?if($this->data['editshelf']['shelf']['photo']){ echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/'.$this->data['editshelf']['shelf']['photo']; }else{?>img/thumnailshefdefault.jpg<?}?>" alt="upimage"></div>
                                            <p class="recommendThumShelf">300 x 300 px</p>
                                            <button class="btnBrowseTmbnl btnCreateS" id="shelfBtn" type="button">+ Image</button>
                                        </div>
                                        <div class="wrapTitleandDsctShelf">
                                            <input class="inptTitleShelf inptTitleDsct" id="title" name="title" value="<?=$this->data['editshelf']['shelf']['title']?>" type="text" placeholder="Title">
                                            <textarea class="inptDsctShelf inptTitleDsct" id="descritpion" name="descritpion" placeholder="Description" value=""><?=$this->data['editshelf']['shelf']['descritpion']?></textarea>
                                            <!--<input class="inptTitleShelf inptTitleDsct" id="itune" name="itune" value="<?=$this->data['editshelf']['shelf']['itune']?>" type="text" placeholder="https://itunes.apple.com/us/app/infostant/id548216775">
                                            <input class="inptTitleShelf inptTitleDsct" id="schema" name="schema" value="<?=$this->data['editshelf']['shelf']['schema']?>" type="text" placeholder="schema of shelf">-->
                                            <!--<input style="display: none;" type="file" name="pem" id="pem">-->
                                            <!-- <div id="wrapPEM" class="inptFilePem inptTitleDsct"><div id="pemfiletarget-0"><? if($this->data['editshelf']['shelf']['pemfile']){?><a target="_blank" href="<?=fileinfo.'/'.$this->data['editshelf']['shelf']['shelfid'].'/'.$this->data['editshelf']['shelf']['pemfile']?>">PEM</a><?}else{?>Click Get PEM<?}?></div></div> -->
                                            
                                            <div class="addPem" style="display: none;">
                                                <div class="wrapInptPem wrapTmbnlFileType" id="wrapPEM">
                                                    <div class="wrapInPem">
                                                        <div class="tmbnlFileType">
                                                            <i class="bookTypeIcon">
                                                                <div id="pemfileload-0" class="load5 loading"></div>
                                                                <div class="topRight"></div>
                                                                <div class="bottomLeft"></div>
                                                                <p class="bookType5" id="pemfiletarget-0">.PEM</p>
                                                            </i>
                                                            <button id="btnAddfile5"  class="btnAddfile5 btnAddF btnAddU" onclick="return false">+ file</button>
                                                            <button id="btnDelfile5" class="btnDelfile5 btnAddD btnAddU" onclick="return false">-</button>
                                                        </div>
                                                    </div>
                                                    <input class="inptPwdPem inptTitleDsct" style="margin-top: 10px;" id="passpem" name="passpem" value="<?=$this->data['editshelf']['shelf']['passpem']?>" type="password" placeholder="Password of PEM">
                                                </div>
                                            </div>
                                            <div class="wrapAddTag">
                                                  <p>Create tags</p>
                                                  <input type="text" id="tagnameadd" name="tagnameadd" class="inputTextTag" placeholder="+ Add tags here">
                                                  <input type="button" id="addTag" value="add" />
                                                  <div class="wrapAddTagShow">
                                                        <div id="tagWrpShowTag">
                                                            
                                                        </div>
                                                  </div>
                                            </div>
                                            <div class="wrapAddType" style="display: none;">
                                                  <p>Create book types</p>
                                                  <input type="text" id="catnameadd" name="catnameadd" class="inputTextType" placeholder="+ Add tags here">
                                                  <input type="button" id="addType" value="add" />
                                                  <div class="wrapAddTypeShow">
                                                        <div id="typeWrpShowCat">
                                                            
                                                        </div>
                                                  </div>
                                            </div>
                                        </div>
                                        
                              <!--          
                                        <div class="wrapAddUIU">
                                            <div class="addSlide">
                                                <div class="wrapUIUDef">
                                                    <div class="wrapTumbnlDef">
                                                        <div class="upUIU">
                                                            <div id="droppic1"><img id="imgbanner1" class="upUIUA" src="<?if($this->data['editshelf']['banner'][0]['photo']){echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/banner/'.$this->data['editshelf']['banner'][0]['photo'];}else{?>img/banner.png<?}?>" alt="upimage">
                                                            <?if(!$this->data['editshelf']['banner'][0]['photo']){?>
                                                            <div class="upUIUA">
                                                                <button class="btnAddUIU btnAddU" id="bannerBtn1" type="button">+ Store Banner</button>
                                                            </div>
                                                            <?}?>
                                                            </div>
                                                            <div class="upUIUA recSugBar recBar">
                                                                <input class="inptLink" value="<?=$this->data['editshelf']['banner'][0]['link']?>" id="bannerLink-1" type="text" placeholder="Link">
                                                                <p class="recUIU textUnderTumbnl">Store Banner Size : 960 x 460 px</p>
                                                                <button class="btnRemoveUIU" onclick="resetbanner(1)">Remove this banner</button>
                                                            </div>
                                                        </div>
                                                        <div class="upUIU">
                                                          <div id="droppic2">
                                                            <img id="imgbanner2" class="upUIUA" src="<?if($this->data['editshelf']['banner'][1]['photo']){echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/banner/'.$this->data['editshelf']['banner'][1]['photo'];}else{?>img/banner.png<?}?>" alt="upimage">
                                                            <?if(!$this->data['editshelf']['banner'][1]['photo']){?>
                                                            <div class="upUIUA">
                                                                <button class="btnAddUIU btnAddU" id="bannerBtn2" type="button">+ Store Banner</button>
                                                            </div>
                                                            <?}?>
                                                            </div>
                                                            <div class="upUIUA recSugBar recBar">
                                                                <input class="inptLink" id="bannerLink-2" value="<?=$this->data['editshelf']['banner'][1]['link']?>" type="text" placeholder="Link">
                                                                <p class="recUIU textUnderTumbnl">Store Banner Size : 960 x 460 px</p>
                                                                <button class="btnRemoveUIU" onclick="resetbanner(2)">Remove this banner</button>
                                                            </div>
                                                        </div>
                                                        <div class="upUIU">
                                                            <div id="droppic3">
                                                            <img id="imgbanner3" class="upUIUA" src="<?if($this->data['editshelf']['banner'][2]['photo']){echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/banner/'.$this->data['editshelf']['banner'][2]['photo'];}else{?>img/banner.png<?}?>" alt="upimage">
                                                            <?if(!$this->data['editshelf']['banner'][2]['photo']){?>
                                                            <div class="upUIUA">
                                                                <button class="btnAddUIU btnAddU" id="bannerBtn3" type="button">+ Store Banner</button>
                                                            </div>
                                                            <?}?>
                                                            </div>
                                                            <div class="upUIUA recSugBar recBar">
                                                                <input class="inptLink" id="bannerLink-3" value="<?=$this->data['editshelf']['banner'][2]['link']?>" type="text" placeholder="Link">
                                                                <p class="recUIU textUnderTumbnl">Store Banner Size : 960 x 460 px</p>
                                                                <button class="btnRemoveUIU" onclick="resetbanner(3)">Remove this banner</button>
                                                            </div>
                                                        </div>
                                                        <div class="upUIU">
                                                        <div id="droppic4">
                                                            <img id="imgbanner4" class="upUIUA" src="<?if($this->data['editshelf']['banner'][3]['photo']){echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/banner/'.$this->data['editshelf']['banner'][3]['photo'];}else{?>img/banner.png<?}?>" alt="upimage">
                                                            <?if(!$this->data['editshelf']['banner'][3]['photo']){?>
                                                            <div class="upUIUA">
                                                                <button class="btnAddUIU btnAddU" id="bannerBtn4" type="button">+ Store Banner</button>
                                                            </div>
                                                            <?}?>
                                                        </div>
                                                            <div class="upUIUA recSugBar recBar">
                                                                <input class="inptLink" id="bannerLink-4" value="<?=$this->data['editshelf']['banner'][3]['link']?>" type="text" placeholder="Link">
                                                                <p class="recUIU textUnderTumbnl">Store Banner Size : 960 x 460 px</p>
                                                                <button class="btnRemoveUIU" onclick="resetbanner(4)">Remove this banner</button> 
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="dotPage">
                                                <div class="dotOut dotP1 dotIn"></div>
                                                <div class="dotOut dotP2 "></div>
                                                <div class="dotOut dotP3 "></div>
                                                <div class="dotOut dotP4 "></div>
                                            </div>
                                        </div>
                                    
                                    
                                          <div class="wrapAddUIU">
                                            <div class="addSlide">
                                                <div class="wrapUIUDef">
                                                    <div class="wrapTumbnlDefL">
                                                        <div class="upUIU">
                                                            <div id="droppic5">
                                                            <img id="imgbanner5" class="upUIUA" src="<?if($this->data['editshelf']['bannerlibrary'][0]['photo']){echo imginfo."/".$this->data['editshelf']['shelf']['shelfid'].'/banner/'.$this->data['editshelf']['bannerlibrary'][0]['photo'];}else{?>img/banner.png<?}?>" alt="upimage">
                                                            <?if(!$this->data['editshelf']['bannerlibrary'][0]['photo']){?>
                                                            <div class="upUIUA">
                                                                <button class="btnAddUIU btnAddU" id="bannerBtn5" type="button">+ Library Banner</button>
                                                            </div>
                                                            
                                                            <?}?>
                                                            </div>
                                                            <div class="upUIUA recSugBar recBar">
                                                                <input class="inptLink" id="bannerLink-5" type="text" value="<?=$this->data['editshelf']['bannerlibrary'][0]['link']?>" placeholder="Link">
                                                                <p class="recUIU textUnderTumbnl">Library Banner Size : 960 x 460 px</p>
                                                                <button class="btnRemoveUIU" onclick="resetbannerlibrary(5)">Remove this banner</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        -->
                                                          <div class="wrapAddUIU"></div>
                                            <input type="hidden" value="<?=$this->data['editshelf']['shelf']['shelfid']?>" name="shelfid" id="shelfid" >
                                        </div>
                                            <div class="wrapCreateUserandTable" style="min-height:250px">
                                                <p class="textCreateUser titleCreate">เพิ่มสมาชิก</p>
                                                <!--<form class="userGroup" id="userGroup"> -->
                                                <div class="wrapCreateUser">
                                                
                                        <div class="wrapTmbnlShelf imgUserUpload">
                                            <div id="droppic2"><img id="imgshelf2" class="upThumImg" src="img/thumnailshefdefault.jpg" alt="upimage"></div>
                                            <p class="recommendThumShelf">300 x 300 px</p>
                                            <button class="btnBrowseTmbnl btnCreateS" id="shelfBtn2" type="button">+ Image</button>
                                        </div>
                                                
                                                
                                                
                                                
                                                    <input class="inptNameUser inptUser" name="usernameadd" id="usernameadd" type="text" placeholder="Username">
                                                    <input class="inptEmailUser inptUser" name="emailadd" id="emailadd" type="text" placeholder="Email">
                                                    <input class="inptNameUser inptUser" name="firstnameadd" id="firstnameadd" type="text" placeholder="Firstname">
                                                    <input class="inptPwdUser inptUser"name="passwordadd" id="passwordadd" type="password" placeholder="รหัสผ่าน">
                                                    <button class="btnCreateUser btnCreateS" id="userAddBtn" type="button"  >เพิ่ม</button>
                                                </div>
                                                <div class="wrpOuterCreateUserandTable">  
                                                    <table class="wrapTableUser" id="wrapTableUser">
                                                       <thead>
                                                        <tr>
                                                            <th>ลำดับ</th>
                                                            <th>Username</th>
                                                            <th>Email</th>
                                                            <th>Firstname</th>
<!--                                                            <th>Password</th>-->
                                                            <th>Reset</th>
                                                           <th>Admin</th>
                                                           <th>Edit</th>
                                                            <th>ลบ</th>
                                                        </tr>
                                                       </thead>
                                                      <tbody>
                                                      </tbody>  
                                                    </table>
                                                </div>    

                                            </div> 
                                    </div>
                        
                                </div>
                                <div class="wrapBtnCreateShelf">
                                    <button class="btnCreateShelf btnCreateS" type="button" onclick="saveshelfbook()"><?if($this->data['label']){ echo $this->data['label']; }else {?>Create <?}?> </button>
                                </div>
                            <!--</form>-->
                        </div>
                    </div>
                </div>
            </div>

            <script type="text/javascript" src="js/createshelf.js"></script> 
            <?
            if(count($this->data['editshelf']))
            {
            ?>
            <script>

            // loading bar 5
           // $('.btnAddfile5').click(function(){
//                $(".load5").show();
//                $(".load5").each(function() {
//                    $(this)
//                        .data("origWidth",$(this).height())
//                        .height(0)
//                        .animate({ 
//                            height: $(this).data("origWidth")
//                        }, 1200);
//                });
//            });
//            $('.btnDelfile5').click(function(){
//                $(".load5").hide();
//            });
            // loading bar 5

            $(function() {
            <?
            
            if(count($this->data['editshelf']['user'])){
            foreach($this->data['editshelf']['user'] as $valueuser){?>
            addUserByEdit('<?=$valueuser['userid']?>','<?=$valueuser['username']?>','<?=$valueuser['email']?>','<?=$valueuser['roleid']?>','<?=$valueuser['firstname']?>','<?=$valueuser['photo']?>');
            <?
            }
            }
            ?>
            
            
            
            oTable = $('#wrapTableUser').dataTable();
            
            
            
            <?
            
            
            
            
            if(count($this->data['editshelf']['cat'])){
            foreach($this->data['editshelf']['cat'] as $valuecat){?>
            addCatByEdit('<?=$valuecat['catid']?>','<?=$valuecat['name']?>');
            <?
            }
            }
            
            
            if(count($this->data['editshelf']['tag'])){
            foreach($this->data['editshelf']['tag'] as $valuetag){?>
            addTagByEdit('<?=$valuetag['tagid']?>','<?=$valuetag['name']?>');
            <?
            }
            }
            
            if($this->data['editshelf']['shelf']['photo'])
            {
            
            ?>
            $("#filebirdsavename-0").val('<?=$this->data['editshelf']['shelf']['photo']?>');
            <?
            
            }
             
              for($i=0;$i<4;$i++)
             {
              if($this->data['editshelf']['banner'][$i]['photo'])
             {?>
            $("#filebirdsavename-<?=($i+1)?>").val('<?=$this->data['editshelf']['banner'][$i]['photo']?>');
            
            
            <?}
              }
              
              
              if($this->data['editshelf']['bannerlibrary'][0]['photo'])
             {?>
            $("#filebirdsavename-5").val('<?=$this->data['editshelf']['bannerlibrary'][0]['photo']?>');
            
            
            <?}
            
           
            if($this->data['editshelf']['shelf']['pemfile'])
            {
            ?>
            $("#file2birdsavename-0").val("<?=$this->data['editshelf']['shelf']['pemfile']?>");
            $("#pemfileload-0").css("height",81);
            $("#pemfileload-0").show();
        $("#pemfiletarget-0").html('<a target="_blank" href="'+fileinfo+'/<?=$this->data['editshelf']['shelf']['shelfid']?>/<?=$this->data['editshelf']['shelf']['pemfile']?>">PEM</a>');
            //$(".pdfType").css("background-color","#cfcfcf");
         //   $(".wrapPdf").show();
           <?}?>
            
            });
            </script>
           <?
              }
        require_once('footer.php'); // uri  
           ?>